#include "iConfig.hpp"

#include <glf/core/condition.h>

#if GLF_ENABLE_DEBUGGER
#	include <glf/debugger/profiler.h>
#endif
 
#if __APPLE__
	#include "synchronization_posix_.hpp"
#else
	#include GLFi_HEADER_API(synchronization, GLF_API_THREAD)
#endif

namespace glf
{

Condition::Condition(Mutex &mut)
	: m(GLF_NEW_IMPL(mut))
{
	GLF_CHECK_IMPL_SIZE();
}

Condition::~Condition()
{
	GLF_DELETE_IMPL();
}

int Condition::Signal()
{
#if GLF_ENABLE_DEBUGGER
	debugger::SynchronizationScopeEvent dbgScopeEvent(debugger::sConditionEventType, "[glf] Condition::Signal", (int)this);
#endif

	return m.Signal();
}

int Condition::Broadcast()
{
#if GLF_ENABLE_DEBUGGER
	debugger::SynchronizationScopeEvent dbgScopeEvent(debugger::sConditionEventType, "[glf] Condition::Broadcast", (int)this);
#endif

	return m.Broadcast();
}

int Condition::Wait(unsigned int time)
{
#if GLF_ENABLE_DEBUGGER
	debugger::SynchronizationScopeEvent dbgScopeEvent(debugger::sConditionEventType, "[glf] Condition::Wait", (int)this);
#endif

	return m.Wait(time);
}

} //namespace glf
